<jsp:include page="includes/header.jsp">
        <jsp:param name="title" value="Materiais" />
</jsp:include>
<jsp:include page="includes/menuLateral.jsp"/>
<div id="centro" >
<jsp:useBean id="bo" class="br.uniceub.fsw.academicmobile.control.MaterialBO" />

		<script>
			function validaSelecao(form){
                            var retorno = true;
                            if(PegarIdRadioSelecionado() == -1){
                                    alert("Nenhum material selecionado");
                                    retorno = false;
                            } else {
                                if(document.forms[0].operacao.value=="excluir") {
                                    return confirm("Tem certeza que deseja excluir o material selecionado ?");
                                }
                            } 
                            return retorno;
			}
		
			function alterar(){
                            document.forms[0].action = "alterarMaterial.jsp";
                            document.forms[0].operacao.value="telaAlterar";
                            document.forms[0].idMaterial.value = PegarIdRadioSelecionado();
			}
			
			function excluir(){
                            document.forms[0].action = "confirmacao.jsp";
                            document.forms[0].operacao.value="excluir";
                            document.forms[0].idMaterial.value = PegarIdRadioSelecionado();
			}
		
			function inicio() {
                            top.document.location.href = "professor.jsp";
			}
			
			function incluir() {
                            top.document.location.href = "incluirMaterial.jsp";
			}
			
			function PegarIdRadioSelecionado() {
                            var id = -1;
                            var pR = document.getElementsByName('radio');
                            for(var i=0; i<pR.length; i++) {
                                    if(document.getElementsByName('radio')[i].checked == true) {
                                            id = document.getElementsByName('radio')[i].value;
                                            break;
                                    }
                            }
                            return id;
			}
		</script>

		
		<div id="links">
			<table width="100%">
				<tr>
					<td width="50%" align="left"><input type="button" value="Inicio" onclick="inicio()"/></td>
					<td width="50%" align="right"><input type="button" value="Novo" onclick="incluir()"/></td>
				</tr>
			</table>
		</div>
		<form method="POST" action="alterar.jsp" enctype="multipart/form-data" onsubmit="return validaSelecao(this)">
		<div id="conteudo" align="center">

			<%=bo.getTabelaMateriais(request)%>
			
		</div>
		</form>
</div>
  <jsp:include page="includes/rodape.jsp" />
